package com.chai.controller;

import com.chai.domain.Book;
import org.springframework.web.bind.annotation.*;

/**
 * 按照REST风格
 * @RestController整合@Controller、@ResponseBody
 *
 * */
/*@Controller
@ResponseBody*/
@RestController
@RequestMapping("/books")
@ResponseBody
public class BookController {
    /**
     * @RequestBody使用json发送数据
     * */
    @PostMapping
    public String save(@RequestBody Book book){
        System.out.println("save ...");
        return "";
    }
    /**
     * 根据id进行删除指定的记录
     * */
    @DeleteMapping("/{id}")
    public String delete(@PathVariable int id){
        System.out.println("delete ...");
        return "";
    }
    @GetMapping
    public Book selectAll(@RequestBody Book book){
        System.out.println("selectAll ...");
        return book;
    }
    @PutMapping("/{id}")
    public String updateById(@PathVariable int id){
        System.out.println("updateById ....");
        return "";
    }

}
